<?php if (!$noview) { ?>
<div class="teamRankings">
<h2><?php __('Teams Ranking');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
	<th><?php echo $paginator->sort(__('Group',true), 'TeamRanking.iGroup');?></th>
	<th><?php echo $paginator->sort(__('#',true), 'TeamRanking.iRanking');?></th>
	<th><?php echo $paginator->sort(__('Team',true), 'Team.strName');?></th>
	<th><?php echo $paginator->sort(__('Race',true), 'Race.ID');?></th>
	<th><?php echo $paginator->sort(__('Coach',true), 'Coach.ID');?></th>
	<th><?php echo $paginator->sort(__('Pts',true), 'TeamRanking.iPoints');?></th>
	<th><?php echo $paginator->sort(__('W',true), 'TeamRanking.iWins');?></th>
	<th><?php echo $paginator->sort(__('D',true), 'TeamRanking.iDraws');?></th>
	<th><?php echo $paginator->sort(__('L',true), 'TeamRanking.iLosses');?></th>
	<th><?php echo $paginator->sort(__('Tv',true), 'TeamRanking.iTeamValue');?></th>
</tr>
<?php
$i = 0;
foreach ($teamRankings as $teamRanking):
	$class = null;
	if ($i++ % 2 == 0) {
		$class = ' class="altrow"';
	}
?>
	<tr<?php echo $class;?>>
		<td><?php echo $teamRanking['TeamRanking']['iGroup']; ?></td>
		<td><?php echo $teamRanking['TeamRanking']['iRanking']; ?></td>
		<td><?php echo $html->link($teamRanking['Team']['strName'], array('controller' => 'teams', 'action' => 'view', $teamRanking['Team']['ID'])); ?></td>
		<td><?php echo $html->link($teamRanking['Team']['Race']['LocalizedString'][$locale], array('controller' => 'races', 'action' => 'view', $teamRanking['Team']['Race']['ID'])); ?></td>
		<td><?php
		if(!isset($teamRanking['Team']['Coach']['strName'])) {
			 echo 'Unknown';
		} else {
			echo $html->link($teamRanking['Team']['Coach']['strName'], array('controller' => 'coaches', 'action' => 'view', $teamRanking['Team']['Coach']['ID'])); }?></td>
		<td><?php echo $teamRanking['TeamRanking']['iPoints']; ?></td>
		<td><?php echo $teamRanking['TeamRanking']['iWins']; ?></td>
		<td><?php echo $teamRanking['TeamRanking']['iDraws']; ?></td>
		<td><?php echo $teamRanking['TeamRanking']['iLosses']; ?></td>
		<td><?php echo $teamRanking['TeamRanking']['iTeamValue']; ?></td>
	</tr>
<?php endforeach; ?>
</table>

<div class="paging">
	<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
 | 	<?php echo $paginator->numbers();?>
	<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
</div>
</div>
<?php } ?>